package com.example.myvertx.config;

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.util.VersionUtil;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

/**
 * json: long to string
 * @author junjie.yang
 * @date 2022/9/5
 */
public class LongToStrModule extends Module {
    @Override
    public String getModuleName() {
        return LongToStrModule.class.getSimpleName();
    }

    @Override
    public Version version() {
        return VersionUtil.versionFor(LongToStrModule.class);
    }

    @Override
    public void setupModule(SetupContext context) {
        SimpleModule simpleModule = new SimpleModule();
        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
        simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
        simpleModule.setupModule(context);
    }
}
